package com.molichuxing.services.infrastructure.service.impl;

import com.molichuxing.services.infrastructure.bean.CheckPreparationBean;
import com.molichuxing.services.infrastructure.convertor.Convert;
import com.molichuxing.services.infrastructure.dao.CheckPreparationMapper;
import com.molichuxing.services.infrastructure.dto.request.modify.CheckPreparationModifyDto;
import com.molichuxing.services.infrastructure.dto.response.CheckPreparationDto;
import com.molichuxing.services.infrastructure.service.CheckPreparationService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * <p>
 * 车辆整备表 服务实现类
 * </p>
 *
 * @author 
 * @since 2019-08-15
 */
@Service("checkPreparationService")
public class CheckPreparationServiceImpl implements CheckPreparationService {

  private static final Logger log = Logger.getLogger(CheckPreparationServiceImpl.class);

  @Resource
  private CheckPreparationMapper checkPreparationMapper;



  @Override
  public CheckPreparationDto getCheckPreparation(Integer checkId) {
    return Convert.toCheckPreparationDto(checkPreparationMapper.getByCheckId(checkId));
  }


  @Override
  @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
  public int createCheckPreparation(Integer checkId,CheckPreparationModifyDto checkPreparationModifyDto) {
    CheckPreparationBean checkPreparationBean  = Convert.toCheckPreparationBean(checkId,checkPreparationModifyDto);
    return checkPreparationMapper.insertCheckPreparationBean(checkPreparationBean);
  }


}
